#!/usr/bin/perl
use File::Basename;
use File::chdir;
$path = @ARGV[0];
#if ($path)
#{
#        print "Searching $path for files\n";
#}else{
#        $path = ".";
#}

chomp(@rars = `find $path -type f -name '*.r00' -o -name '*.part01.rar'`);
chomp(@delete = `find $path -type f -name '*.r[0-9][0-9]' -o -name '*.part[0-9][0-9].rar' -o -name '*.rar'`);

print $path;
for ($i=0; $i<@rars; $i++)
{
       	$CWD = dirname(@rars[$i]);
	$file = basename(@rars[$i]);
	system("unrar x -cl $file");
#     	system("unrar x $file > $path/vagina.txt");
}

for ($i=0; $i<@delete; $i++)
{
	unlink("@delete[$i]") or die " cant delete @delete[$i] ";
}

